package com.ktjy.controller;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktjy.mapper.UserMapper;
import com.ktjy.pojo.TSysUser;
import com.ktjy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lqm
 * @ClassName UserCoutroller
 * @description: TODO
 */
@RestController
public class UserCoutroller {
    @Autowired
    UserService userService;

    @RequestMapping("/getCount")
    public String getCount(){
        System.out.println("共有"+userService.count()+"条数据！");
        return "共有"+userService.getAllCount()+"条数据！";
    }


    @RequestMapping("/getList")
    public String getList(){
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.like("realname","2");
        Page<TSysUser> page = new Page<TSysUser>(1,2);
        IPage<TSysUser> userPager = userService.page(page,queryWrapper);


        return JSON.toJSONString(userPager);
    }
}
